package com.hn.mapper;

import com.hn.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {
//    @Select("select count(*) from emp")
//    Long count();
//    @Select("select * from emp limit #{start},#{pageSize}")
//    List<Emp> select(Integer start,Integer pageSize);
//    @Select("select * from emp")
//    List<Emp> select();//结合pageHelper，代替上面2个
    //结合PageHelper和xml实现分页条件查询
    List<Emp> select(String name, Short gender, LocalDate begin, LocalDate end);
    void delete(Integer[] ids);
    @Insert("insert into emp values(null,#{username},#{password},#{name}," +
            "#{gender},#{image},#{job},#{entrydate},#{deptId},now(),now())")
    void add(Emp emp);
    @Select("select * from emp where id=#{id}")
    Emp selectById(Integer id);

    void update(Emp emp);
    //根据部门删除emp
    @Delete("delete from emp where dept_id=#{id}")
    void deleteByDeptId(Integer id);
}
